﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EWineShop.Service.Contracts;
using EWineShop.Service;
using EWineShop.Service.Model;

namespace EWineShop.AdminSite.Controllers
{
    public class FoodDepartmentController : Controller
    {
        IIDCreaterService IIDCreater = new IDCreaterService();
        IFoodDepartmentService IFoodDepartment = new FoodDepartmentService();

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Save(FormCollection collection)
        {

            FoodDepartmentModel model = new FoodDepartmentModel()
            {

                FoodDepartmentID = IIDCreater.GetNewID("FoodDepartmentID", "菜品部门ID", 1000),
                Name = collection["txtName"],
                Remark = "",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Parse("1900-01-01")
            };

            IFoodDepartment.AddFoodDepartment(model);

            return null;
        }

        public ActionResult Update(FormCollection collection)
        {
            FoodDepartmentModel model = new FoodDepartmentModel()
            {
                FoodDepartmentID = Int64.Parse(collection["HDfoodCategoryID"]),
                Name = collection["txtName"],
                Remark = "",
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now
            };

            IFoodDepartment.UpdateByFoodDepartmentID(model);

            return null;

        }

        public ActionResult Delete(Int64 id)
        {
            IFoodDepartment.DeleteByFoodDepartmentID(id);
            return null;
        }

    }
}
